﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

namespace Wagner.SharePoint.Utilities
{
	public class SPDevTimerJob : SPJobDefinition
	{
		public SPDevTimerJob()
			: base()
		{ }

		public SPDevTimerJob(string jobName, SPService service, SPServer server, SPJobLockType targetType)
			: base(jobName, service, server, targetType)
		{ }

		/// <summary>
		/// Processes each email in the email queue for each registered site collection in the web application.
		/// </summary>
		/// <param name="jobName"></param>
		/// <param name="webApplication"></param>
		/// <remarks>
		/// We need to set the lock type to "Job" so the job runs on only one web server, the web 
		/// server where the job is first initiated, and not every web server in the farm.  Setting the lock 
		/// to "None" will cause the job to run on every web server when the job is initiated. A lock
		/// value of "Database" 'appears' to run the job on every web server.
		/// </remarks>
		public SPDevTimerJob(string jobName, SPWebApplication webApplication)
			: base(jobName, webApplication, null, SPJobLockType.Job)
		{
			this.Title = SPDevTimerJob.JobName;
		}

		internal static string JobName
		{
			get { return "SPDev: Timer Job Tester"; }
		}
		
		public override void Execute(Guid contentDbId)
		{
			SPWebApplication webApp = this.Parent as SPWebApplication;
		}

	}
}
